class Solution {
public:
    string baseNeg2(int n) {
        if (n == 0) return "0";
        string ans;
        while (n)
        {
            int mod = n % (-2);
            n /= (-2);
            if (mod == -1)
                ++n, mod = 1;
            ans += to_string(mod);
        }
        reverse(ans.begin(), ans.end());
        return ans;
    }
};